The present invention relates generally to the field of memory devices and, more particularly, to content addressable memory (CAM) devices and methods of operating same.
In many memory devices, including random access memory (RAM) devices, data is typically accessed by supplying an address to an array of memory cells and then reading data from the memory cells that reside at the supplied address. In content addressable memory (CAM) devices, however, data within a CAM array is not accessed by initially supplying an address, but rather by initially applying data to the array and then performing a compare operation to identify one or more locations within the array that contain data equivalent to the applied data and thereby represent a xe2x80x9cmatchxe2x80x9d condition. In this manner, data may be accessed according to its content in addition to being accessible by its address. Upon completion of the compare operation, the identified location(s) containing equivalent data is typically encoded to provide an address at which the equivalent data is located. If multiple locations are identified in response to the compare operation, then priority encoding operations may be performed to identify a best or highest priority match. Such priority encoding operations frequently use the physical locations of multiple matches within the CAM array to identify a highest priority match. Exemplary CAM cells and CAM memory devices are more fully described in U.S. Pat. Nos. 5,706,224, 5,852,569 and 5,964,857 to Srinivasan et al. and U.S. Pat. Nos. 6,101,116, 6,256,216 and 6,128,207 to Lien et al., assigned to the present assignee, the disclosures of which are hereby incorporated herein by reference.
CAM cells are frequently configured as binary CAM cells that store only data bits (as xe2x80x9c1xe2x80x9d or xe2x80x9c0xe2x80x9d logic values) or as ternary CAM cells that store data bits and mask bits. As will be understood by those skilled in the art, when a mask bit within a ternary CAM cell is inactive (e.g., set to a logic 1 value), the ternary CAM cell may operate as a conventional binary CAM cell storing an xe2x80x9cunmaskedxe2x80x9d data bit. When the mask bit is active (e.g., set to a logic 0 value), the ternary CAM cell is treated as storing a xe2x80x9cdon""t carexe2x80x9d (X) value, which means that all compare operations performed on the actively masked ternary CAM cell will result in a cell match condition regardless of the value of the applied data bit versus the stored data bit. Thus, if a logic 0 data bit is applied to a ternary CAM cell storing an active mask bit and a logic 1 data bit, the compare operation will indicate a cell match condition. A cell match condition will also be indicated if a logic 1 data bit is applied to a ternary CAM cell storing an active mask bit and a logic 0 data bit. Accordingly, if a data word of length N, where N is an integer, is applied to a ternary CAM array having a plurality of entries therein of width N, then a compare operation will yield one or more entry match conditions whenever all the unmasked data bits of a word stored in the ternary CAM array are identical to the corresponding data bits of the applied word. This means that if the applied data word equals {1011}, the following stored words will result in an entry match condition in a CAM comprising ternary CAM cells (i.e., a ternary CAM): {1011}, {X011}, {1X11}, {10X1}, {101X}, {XX11}, {1XX1}, . . . , {1XXX}, {XXXX}.
Applications using CAMs include database management, disk caching, pattern and image recognition and artificial intelligence. CAMs are also well suited for use in routing network traffic, such as in network address lookup or packet switching. For example, FIG. 1 illustrates a simplified view of a network switch 100. The network switch 100 may communicate with a network through a plurality of network ports, shown as ports zero through seven. The switch 100 may receive network traffic on one port and determine to which of its other ports that traffic should be routed. As will be understood by those skilled in the art, the network traffic may include a packet stream of data containing a leading destination address. The network switch 100 may select a leading portion of the packet stream and provide it to a ternary CAM 102. The CAM 102 may contain entries that include predetermined routing information, with the CAM address of each of these entries designating a port of the network switch 100. When the portion of the packet stream is applied as data to the CAM 102 during a compare operation, the CAM 102 may return a CAM address. This CAM address may correspond to the location of an entry within the CAM 102 that matches the applied portion of the packet stream. This returned CAM address may then be used by the network switch 100 as a pointer to acquire routing information from a second memory device to direct the packet stream to a desired port that will enable the packet stream to reach its destination address.
Referring now to FIG. 2, a conventional network routing application may also use a switch controller 200 that receives network packets from an external source and routes the network packets through a switch 206. The switch controller 200 may provide a portion of a destination address within a packet to an accompanying CAM 202. In response, the CAM 202 may perform a compare operation and generate an address of a matching entry. This generated address may be used as a pointer to acquire network address translation information or other routing information contained within a RAM 204. The information provided by the RAM is then conveyed to the controller 200 for use in routing the packet through the switch 206. In this manner, a CAM 202 may be used to provide a mechanism for locating address translation and routing information for network packet addresses.
In the event multiple matches (i.e., multiple matching entries) are detected during a compare operation, conventional physical priority encoding techniques may be used to identify a best or highest priority match (i.e., a highest priority matching entry) that should be used to perform the routing of the packet stream in a preferred manner. This highest priority match is frequently referred to as a longest prefix match (LPM), where the prefix may be defined as a first portion of a network packet address. A conventional technique for identifying an LPM will now be described with reference to the entries illustrated within the CAM 102 of FIG. 1. If the destination address within the packet stream is a bit sequence equal to {01100010}, then a compare operation within the CAM 102 of FIG. 1 will result in three matches. These three matches correspond to the entries at address 0, designating port 0, address 3, designating port 3, and address 6, designating port 6. As illustrated by the entries within the CAM 102, the match corresponding to the entry at address 0 may be treated as the highest priority match because it is the entry with the largest number of unmasked data bits that are equivalent to the applied destination address. The detection of this highest priority match can be relatively simple if the entries within the CAM 102 are presorted according to priority or are arranged within sectors, with each sector containing entries having the same number of unmasked bits and being physically arranged according to priority. As described herein, sectors within a CAM may have the same or different number of entries therein.
As illustrated by FIG. 1, entries having no masked bits may be stored in a first sector (illustrated as spanning addresses 0-2 within the CAM 102) and entries having only one masked bit may be stored in a second sector (illustrated as spanning only address 3 within the CAM 102). Entries having a greater number of masked bits are also stored in respective lower priority sectors within the CAM 102. By intentionally arranging all entries having the same number of masked bits within the same sector and by physically locating the sectors in order of their priority within the CAM 102, a simple physical encoding technique may be used to identify the highest priority match as the match having the highest number of unmasked bits relative to the other matches. This technique typically includes selecting the match that is in the highest relative priority sector in the event matches within multiple sectors are present. If multiple matches are present within the same highest relative priority sector, then any of the equivalent matches may be selected as the xe2x80x9cbestxe2x80x9d match. Typically, however, the matching entry at the lowest address is selected as the xe2x80x9cbestxe2x80x9d match.
U.S. Pat. No. 6,237,061 to Srinivasan et al., entitled xe2x80x9cMethod For Longest Prefix Matching in a Content Addressable Memory,xe2x80x9d discloses a conventional arrangement of locally masked entries that need not be stored in equivalently sized sectors or blocks within a CAM, but nonetheless are stored by loading a plurality of Class-less Inter-Domain Routing (CIDR) addresses into respective ones of a plurality of CAM entries in a predetermined order such that increasing numerical CAM entry addresses correspond to CIDR addresses having decreasing prefix values (i.e., a greater number of actively masked bits). If a compare operation is then performed and a matching entry within the preordered CAM is present, a suitable match flag signal is asserted, and the index of the matching CAM entry (as well as any associated routing data stored in the CAM or in an external memory such as an SRAM array) is provided as an output. Alternatively, if there are multiple matching entries in the CAM, a suitable multiple match flag signal is asserted and, in response thereto, an associated priority encoder that is coupled to the CAM outputs the highest priority location. This highest priority location corresponds to the CAM entry having the lowest index, which by definition is the longest prefix matching entry.
Partitioning a CAM into a plurality of prioritized sectors may limit the flexibility of the CAM because the content of the CAM may need to be presorted into appropriate sectors according to mask length. Because the sectors are frequently partitioned into arrays of equal size to accommodate a variety of different applications, and because the number of entries required in each sector may be constantly changing during operation, it may not be possible to partition a CAM into fixed sized sectors that do not result in a significant number of unused entry locations. For example, if a CAM is divided into 16 equal sectors to support entries having as many as 15 actively masked bits and each sector is the same size, then much of the CAM may go unused if many of the sectors are only partially filled with entries of a respective mask length. Furthermore, it may not be practical to divide a CAM array into more than a relatively small number M of equally sized sectors because the size of each sector scales as 1/M, some applications may require a large number of priority levels (i.e., large M) and the number of entries at a given priority level may exceed H/M, where H is the height of the CAM (e.g., total number of rows in the CAM array). Finally, even if the CAM is not arranged into equivalently sized sectors, the loading of entries into the CAM in a predetermined order, such that increasing (or decreasing) CAM entry addresses correspond to entries having decreasing (or increasing) prefix values, may require time consuming operations to reload the CAM be performed when new entries having different prefix values are added to the CAM.
Another priority resolution scheme that may be used to select a best match when a database search returns multiple matches involves assigning a weight parameter to each database entry. The weight parameter defines the importance of an entry relative to all other entries in the database. When an entry is added to the database, a second value is written to another database or look-up table that defines that entry""s weight. When a database search returns multiple matching entries, the entry that is associated with the highest weight value is selected as the best match.
Thus, notwithstanding the relative simplicity of determining highest priority matches using conventional physical priority encoding techniques, additional techniques are needed that do not require presorting of entries and do not result in significant amounts of unused CAM space.
According to some embodiments of the present invention, a content addressable memory (CAM) device comprises a CAM array that has multiple entries therein that are arranged in groups by weight class. Each entry comprises data bits and independently searchable weight bits that identify the weight class of the entry. In other embodiments, each entry may comprise one or more table bits, which may be used to define logical tables within the CAM array. The entries within a weight class may be randomly arranged or grouped according to table bit value. Each entry may also comprise one or more validity bits, which indicate whether the entry is in a valid or invalid state. The validity bit(s) may be used to facilitate maintenance of the CAM array as invalid bits may be overwritten with new entries. The data bits may represent an entry value or key, and one or more of the data bits may be actively masked during look-up operations. The CAM entries may be distributed evenly among the groups and/or weight classes or, alternatively, the groups and/or weight classes may have different weight depths (i.e., different numbers of entries).
In further embodiments of the present invention, a CAM array may be searched according to a weight class of a new entry and/or search word to identify a location of one or more entries in the CAM array that are assigned to the same weight class as the new entry. Because the weight bits may be independently searched, one or more of the identified entries may not entirely match the new entry and/or search word. In particular embodiments of the present invention, the CAM array may be searched by applying weight class bits of the new entry and/or search word as differential signals to a first plurality of pairs of differential comparand lines in the CAM array, and applying mask bits to a second plurality of pairs of differential comparand lines in the CAM array that span a data field of each of the entries in the CAM array. These comparand lines may also be referred to as data lines or bit lines.
In still further embodiments of the present invention, a CAM array may be updated by searching the CAM array according to weight class and validity status to identify a location of an empty entry assigned to the same weight class as a new entry. The new entry may then be written into the identified location. It may be determined, however, that there are no empty entries assigned to the same weight class as the new entry. Therefore, in other embodiments of the present invention, the CAM array may be searched according to weight class to identify the top and/or bottom boundary of a weight class block that matches the weight class of a new entry. The weight class block may then be expanded to make room for the new entry.